<?php
if (isset($_SESSION['openid']) && isset($_POST['name']) && isset($_POST['phone']) ){
    include '../c/config.php';
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}
    $openid=$_SESSION['openid'];
    $name=addslashes(trim($_POST['name']));
    $phone=addslashes(trim($_POST['phone']));
    $sheng=addslashes(trim($_POST['sheng']));
    $shi=addslashes(trim($_POST['shi']));
 
    $query=$mysqli->query("select id from uinfo where openid='".$openid."'  limit 0,1 ");
    if($query->num_rows>0){
    	$mysqli->query("update uinfo set name='".$name."',phone='".$phone."',sheng='".$sheng."',shi='".$shi."' where openid='".$openid."' ");
    }else{
    	$mysqli->query("insert into uinfo(openid,name,phone,sheng,shi,laizi,createtime) values('".$openid."','".$name."','".$phone."','".$sheng."','".$shi."','2019','".date("Y-m-d H:i:s")."')  ");
    }
    echo json_encode(array('status'=>'work'));
}else{
    echo json_encode(array('status'=>'not'));
}
